<?php
namespace app\common;
/**
 * @Author: K.EL
 * @Date:   2020-07-16 21:05:38
 * @Last Modified by:   K.EL
 * @Last Modified time: 2020-07-20 01:28:01
 */
class Apiv{
	static function result($success_code=0, $error_code=0, $message='', $result=[]){
		$res = [];
		$res['success_code']=$success_code;
		$res['error_code'] = $error_code;
		$res['result'] = $result;
		if($success_code==0){
			$res['message'] = self::error($error_code);
		}else{
			$res['message'] = $message;
		}
		return json($res);
	}

	static function error($error_code=0){
		$message = '';
		switch ($error_code) {
			case 0: $message = 'OK'; break;
			case 1000: $message = '缺少APPID参数'; break;
			case 1001: $message = '缺少签名参数'; break;
			case 1002: $message = '缺少时间参数'; break;
			case 1003: $message = '参数APPID出错'; break;
			case 1004: $message = '签名出错'; break;
			case 1005: $message = '请求时间被篡改'; break;
			case 1006: $message = '此次API请求已过期'; break;
			
			case 1100: $message = '账户不存在'; break;
			case 1101: $message = '账户被锁定'; break;
			case 1102: $message = '密码错误'; break;
			case 1103: $message = '用户名或手机号已经存在了'; break;

			case 1200: $message = '缺少参数TOKEN'; break;
			case 1201: $message = '登陆失效，请重新登录'; break;
			case 1202: $message = '账户被锁定，请重新登录'; break;

			case 1301: $message = '此账户没有任何权限'; break;
			default: $message = '未知错误';break;
		}
		return $message;
	}

}